//
//  XZHeadeView.m
//  优学荟管理系统
//
//  Created by edz on 2018/1/10.
//  Copyright © 2018年 星道三好. All rights reserved.
//

#import "XZHeadeView.h"

@implementation XZHeadeView {
    UIImageView *iconImage;
}

- (instancetype)initwithStudentName:(NSString *)name {
    if (self == [super init]) {
        [self setupUI:name];
    }
    return self;
}

- (void)setUrl:(NSString *)url {
    _url = url;
    [iconImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"bg_xiangqin_picture_default"]];
}

- (void)setupUI:(NSString *)name {
    self.frame = CGRectMake(0, 0, SCREEN_WIDTH, 126);
    UIImageView *imageV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg_class_head_sculpture_default"]];
    iconImage = [UIImageView new];
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = name;
    nameLabel.font = [UIFont systemFontOfSize:15];
    nameLabel.textColor = [UIColor whiteColor];
    
    [self addSubview:imageV];
    [self addSubview:iconImage];
    [self addSubview:nameLabel];
    
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.height.equalTo(self);
    }];

    [iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(23);
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(iconImage);
        make.left.equalTo(iconImage.mas_right).offset(20);
    }];
}

@end
